<template>
  <div class="">
    <BaseTitle title="住院医嘱" />
    <BaseTable :columns="columns" :loading="loading" :data-source="tableData" :height="210">
      <template #bodyCell="{ column, record }">
        <template v-if="column.dataIndex === 'signStatus'">
          <span v-if="record.advStatus === 0">开立</span>
          <span v-else>已签署</span>
        </template>
        <template v-else-if="column.dataIndex === 'advExecType'">
          <span v-if="record.advExecType === 0">临时</span>
          <span v-else-if="record.advExecType === 1">长期</span>
          <span v-else>出院带药</span>
        </template>
      </template>
    </BaseTable>
  </div>
</template>

<script setup>
const props = defineProps({
  aptmLsh: {
    type: String,
    default: ''
  }
})
const columns = [
  {
    title: '状态',
    width: '100px',
    dataIndex: 'signStatus'
  },
  {
    width: '100px',
    title: '类型',
    dataIndex: 'advExecType'
  },
  {
    title: '处置内容',
    dataIndex: 'advName'
  },
  {
    width: '200px',
    title: '开立医生',
    dataIndex: 'signDoctorName'
  },
  {
    width: '200px',
    title: '签署时间',
    dataIndex: 'signTime'
  }
]
const { loading, tableData, getData } = useTable({
  url: '/inp/zyys/getSignOperateAdviceList',
  pagination: false,
  immediate: false,
  params: {},
  formatParams: () => {
    return {
      aptmLsh: props.aptmLsh
    }
  }
})
watch(
  () => props.aptmLsh,
  (val) => val && getData(),
  {
    immediate: true
  }
)
</script>
<style lang="less" scoped></style>
